/**
  * Created by Joshua Conero(O'Uymas) on 2016/10/28 0028.
  * QQ: 957376074
  * E-mail: Brximl@163.com
  */
import java.net.InetSocketAddress

import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelInitializer
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioServerSocketChannel
class Inet {
  def run():Unit = {
    server()
  }
  def server():Unit = {
    //val bstp = new ServerBootstrap(new NioServerSocketChannel(Executors.newCachedThreadPool(),))
    val bstp = new ServerBootstrap()
    /*
    val group = new NioEventLoopGroup()
    bstp.group(group)
    //bstp.channel(NioServerSocketChannel.class)
    bstp.bind(new InetSocketAddress(6001))
    println("服务器输出内容")
    */
    // https://mauricio.github.io/2015/08/23/http-long-polling-with-scala-and-netty.html
    // NioServerSocketChannel.class(Java) => classOf[NioServerSocketChannel]
    //bstp.group(new NioEventLoopGroup(1),new NioEventLoopGroup()).channel(classOf[NioServerSocketChannel]).childHandler(this)
    val c = bstp.bind(6001).sync().channel()
    //println(bstp)
    println("服务器输出内容")
    c.closeFuture().sync()
  }
}
